package controllers;

import java.util.ArrayList;
import java.util.List;

import models.ResultVo;
import models.ReturnListVo;
import models.SystemColumn;
import models.SystemGrid;

import org.apache.commons.lang.StringUtils;

import services.ColumnService;
import services.GridService;
import vos.ReturnCode;

public class TableController extends BaseController {
	public static void testTable(){
		render();
	}
	public static void getTable(String id){
		if(StringUtils.isEmpty(id)){
			renderFailedJson(ReturnCode.ErrorCode, "表格id不能为空");
		}
		SystemGrid grid=GridService.getGrid(id);
		if(grid==null){
			renderFailedJson(ReturnCode.ErrorCode, "表格不存在");
		}
		List<SystemColumn> column=ColumnService.getColumn(grid.id);
		if(column==null){
			renderFailedJson(ReturnCode.ErrorCode, "没有对应的列");
		}
		List<List<SystemColumn>> lists=new ArrayList<List<SystemColumn>>();
		lists.add(column);
		grid.columns=lists;
		ResultVo vo=new ResultVo(grid);
		renderJSON(vo);
	}
}
